from selenium.webdriver.common.by import By
from pom.base_page import BasePage
import time
from selenium.webdriver.common.action_chains import ActionChains


class LoginPage(BasePage):
    def login_page(self):
        # 账号密码是否大小写敏感
        element = self.driver.find_element(By.CLASS_NAME, "el-input__inner")
        ActionChains(self.driver).double_click(element).perform()

        self.driver.find_element(By.CLASS_NAME, "el-input__inner").send_keys("Admin")
        time.sleep(1)

        # 登录耗时
        start = time.perf_counter()
        self.driver.find_element(By.XPATH, '//*[@id="app"]/div/form/div[3]/div').click()
        end = time.perf_counter()
        cons = end-start

        time.sleep(2)

        temp = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]//div/div[1]/div[1]/div/div[2]/div').text

        # 测试通过则大小写不敏感
        assert temp == "访客人数"
        # 用户登录耗时
        assert cons <= 1.0
